package com.cn.macromazia.controller;

import com.cn.macromazia.commont.util.PhoneUtil;
import com.cn.macromazia.commont.util.RestResult;
import com.cn.macromazia.entity.dto.AddMoUserDTO;
import com.cn.macromazia.service.MoUserService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;


import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;

@Api(tags = "用户")
@RestController
@RequestMapping("/user")
public class UserController {
//    @Resource
//    private UserService userService;
    @Autowired
    private MoUserService moUserService;
//
//    @Resource
//    private UserMapper userMapper;
//    @ApiOperation(value = "查询全部用户")
//    @GetMapping("/queryAll")
//    public Object queryAll(User user){
//        int users = userService.queryAll(user);
//        if (users==1){
//            return "修改成功";
//        }
//        return null;
//    }
//    @GetMapping("/All")
//    public Object queryAll(){
//       return "你好";
//    }
//    @SneakyThrows
//    @PostMapping("/ll")
//    @ApiOperation("条件查询品牌")
//    public Void selctQquey(User user){
//        User user1 = userMapper.selectById(user.getId());
//        SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        Date date = ft.parse(user1.getCretime() + "00:00:00");
//        Date date2 = ft.parse(user1.getEndtime() + "00:00:00");
//        System.out.println(date+"+"+date2);
//      return null;
//    }
@ApiOperation("获取验证码")
@GetMapping(value = "/getCode")
public RestResult<Object> getCode(@RequestParam("phone") String phone) {
    if (!PhoneUtil.isPhoneLegal(phone)) {
        return new RestResult("请输入正确的手机号");
    }
    moUserService.sendMessage(phone);
    return new RestResult("发送成功");

}

    //测试一下
}
